#include "gtest/gtest.h"
#include <acapella/worker/worker.h>
#include <string>

using namespace acapella::delegate;
using namespace acapella::worker;

std::string WorkerTestFunc(const std::string& str)
{
    std::string tmp = str;
    return tmp;
}


TEST(WorkerTest, CompileTest)
{
}

TEST(WorkerTest, NormalSyncRunTest)
{
    typedef functor<std::string(const std::string&)> functor_type;
    typedef TaskWorker<std::string(const std::string&)> worker_type;
    
    worker_type worker(&WorkerTestFunc);
    std::string testString = "hello world";

    std::string str = worker.SyncCall(testString);

    EXPECT_EQ("hello world", str);
}

TEST(WorkerTest, NormalAsynRunTest)
{
    typedef functor<std::string(const std::string&)> functor_type;
    typedef TaskWorker<std::string(const std::string&)> worker_type;
    
    worker_type worker(&WorkerTestFunc);
    std::string testString = "hello world";

    worker.AsynCall(testString);
}
